while (head != null && head.next == target) {
    head = head.next;
}